require "rubygems"
require "active_record"  

    
task :default => :migrate  
desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x"  

task :migrate => :environment do  
    ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil )  
end  
    
task :environment do  
    ActiveRecord::Base.establish_connection(
      :adapter => "sqlite3",
      # TODO: check this
      :dbfile  => "var/yabzs.sqlite"
	)  
    ActiveRecord::Base.logger = Logger.new(File.open('database.log', 'a'))  
end

task :annotate_models => :environment do
	Dir.glob(File.join(File.dirname(__FILE__), 'db/models/*.rb')).each {|f| require f }
	require File.join(File.dirname(__FILE__), "lib/annotate_models.rb")
	AnnotateModels.do_annotations
end
